#[[#define content()]]#
<div class="gray-bg" style="padding:0 10px;height: 100%">
	<div class="row">
		<div class="col-xs-3" style="padding-top: 10px">		
			<div class="ibox">
				<div class="ibox-title">
					<h5>分类目录</h5>
					<div class="pull-right">
						<a href="javascript:" style="font-size:12px;color: #666" onclick="expandAll(true);" title="全部展开">展开</a>
						&nbsp;<a href="javascript:" style="font-size:12px;color: #666" onclick="expandAll(false);" title="全部展开">收起</a>
					</div>
				</div>
				<div class="ibox-content">
					<ul id="ZTree" class="ztree"></ul>
				</div>
			</div>	
		</div>
		<div class="col-xs-9" style="background-color: #fff;">
			#if(autocodeModel.search)
			<div id="AdvanceSearch" style="padding:15px;display: none">
				<form class="form-horizontal" novalidate="novalidate" onsubmit="return bootstrapTableRefresh()">
					<input type="hidden" value="" name="num"/>
					#for(item:columnList)#if(item.search)
					<div class="form-group">
						<label class="col-xs-3 control-label">#(item.name)：</label>
						<div class="col-xs-8">
							#@searchInput(item)
						</div>
					</div>
			    #end#end
					<div class="form-group">
						<div class="col-xs-8 col-xs-offset-3">
							<button type="reset" class="btn btn-default">清空</button>&nbsp;
							<button type="submit" class="btn btn-primary">开始查询</button>&nbsp;
							#if(autocodeModel.is_export=="T")
							<button type="button" onclick="exportData();" class="btn btn-default">数据导出</button>
							<iframe name="uploadIFRAME" width="1" height="1" style="display:none"></iframe>
							<script>
								function exportData(){
									layer.msg("数据正在导出，请稍候...(单次最多导出50000条)");
									uploadIFRAME.location.href="#(firstLowerCase(model))List?is_ajax=T#if(parent)&#(firstLowerCase(parent.code))_id=#[[#(]]##(firstLowerCase(parent.code))_id)#end&is_export=T&pageSize=50000&"+$("#AdvanceSearch form").serialize();
								}
							</script>
							#end
						</div>
					</div>
				</form>
			</div>
			#end
			<div id="toolbar">
				<button onclick="openAddEdit();" type="button" class="btn btn-outline btn-default"><i class="glyphicon glyphicon-plus"></i></button>
			#if(autocodeModel.search)<button onclick="layer.open({area: ['450px', 'auto'],content:$('#AdvanceSearch'),type:1,shade: false,title:'搜索'});" type="button" class="btn btn-outline btn-default"><i class="glyphicon glyphicon-search"></i></button>#end
				<a href="batchDelete#(model)" class="btn btn-outline btn-default" target="selectedTodo" rel="btSelectItem" title="确定删除这些数据？"><i class="glyphicon glyphicon-trash"></i></a>
			</div>
			<table id="bootstrapTable" data-id-field="id" data-url="#(firstLowerCase(model))List#if(parent)?#(firstLowerCase(parent.code))_id=#[[#(]]##(firstLowerCase(parent.code))_id)#end" data-sort-name="id" data-sort-order="desc">
				<thead>
					<tr>
						<th data-checkbox="true"></th>
						<th data-formatter="xuhaoFormatter" data-align="center" data-width="70px">序号</th>
						#for(item:columnList)
						<th #if(item.column=="enable_flag")data-formatter="enableFlagFormatter"#else data-field="#(item.column)#if(item.change)_cn#end" #end data-align="center">#(item.name)</th>
						#end
						<th data-field="create_time" data-align="center" data-width="150px">创建时间</th>
						<th data-formatter="caozuoFormatter">操作</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
</div>
#[[#end]]#
#[[#define css()]]#
<link href="#[[#(res_path)]]#/hplus/css/plugins/ztree/metroStyle/metroStyle.css" rel="stylesheet">
<link href="#[[#(res_path)]]#/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
#[[#end]]#
#[[#define js()]]#
<script src="#[[#(res_path)]]#/hplus/js/plugins/ztree/jquery.ztree.all.min.js"></script>
<script src="#[[#(res_path)]]#/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="#[[#(res_path)]]#/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
#[[#end]]#
#[[#define jsFunction()]]#
<script>
		var zNodes = #[[#(]]#listJSON??"[]");
		
		$().ready(function() {
			$.fn.zTree.init($("#ZTree"), {
				data: {
					simpleData: {
						enable: true
					}
				},
				callback:{
					onClick:treeOnClick
				}
			}, zNodes);
		});
		var #(firstLowerCase(parent.code))_id = 0;
		function treeOnClick(event, treeId, treeNode){
			#(firstLowerCase(parent.code))_id = treeNode.id;
		  $("#AdvanceSearch form").find("input[name='num']").val(treeNode.num);
		  $("#AdvanceSearch form").submit();
		}
		function openAddEdit(){
		  if(#(firstLowerCase(parent.code))_id==0){
			  layer.alert("请先选择#(parent.name)！",{icon:2});
			  return;
		  }
			#if(autocodeModel.full)
		  	layer.full(layer.open({content: 'addEdit#(model)?#(firstLowerCase(parent.code))_id='+#(firstLowerCase(parent.code))_id,type: 2,title: '新增'}));
			#else
				layer.open({area: ['600px', '#(height)px'],content: 'addEdit#(model)?#(firstLowerCase(parent.code))_id='+#(firstLowerCase(parent.code))_id,type: 2,title: '新增'});
			#end
		}
		function expandAll(flag){
			var treeObj = $.fn.zTree.getZTreeObj("ZTree");
			treeObj.expandAll(flag);
		}
	function caozuoFormatter(value,row,index){
		var str = "";
		#if(autocodeModel.full)
			str = str + "<a href=\"javascript:\" onclick=\"layer.full(layer.open({content: 'addEdit#(model)?id="+row.id+"',type: 2,title: '编辑#(autocodeModel.name)'}));\">编辑</a>&nbsp;&nbsp;";
		#else
			str = str + "<a href=\"javascript:\" onclick=\"layer.open({area: ['600px', '#(height)px'],content: 'addEdit#(model)?id="+row.id+"',type: 2,title: '编辑#(autocodeModel.name)'});\">编辑</a>&nbsp;&nbsp;";
		#end
		#if(child)str = str + "<a href=\"javascript:\" onclick=\"layer.full(layer.open({content: '#(firstLowerCase(child.code))List?#(firstLowerCase(model))_id="+row.id+"',type: 2,title: '#(child.name)列表'}));\">#(child.name)列表</a>&nbsp;&nbsp;";#end
		return str;
	}
</script>
#[[#end]]#